package Lee_code;

public class Lee_377 {
    int count;
    int end;
    public int combinationSum4(int[] nums, int target) {
        count = 0;
        end = target;
        dfs(0, nums);

        return count;

    }

    private void dfs(int cur, int[] nums) {

        if(cur==end) {
            count++;
            return;

        } else if (cur>end) {
            return;
        }
        for(int i=0; i< nums.length; i++)
        {
            dfs(cur+nums[i], nums);
        }
    }
}
